﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.User;
using CE.Global;
using CE.Provider;

public partial class Provider_PersonalAccident_AddNewPAInsurance : System.Web.UI.Page
{
    string PageName = "CXPA";
    string SubPageName = "CXPACB";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (!IsPostBack)
        {
            ClearProcess();
            Int64 _painsid;
            Int64 _pacompanyid = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            if (Request.Params["PAInsId"] != null)
            {
                if (Int64.TryParse(Request.Params["PAInsId"].ToString(), out _painsid))
                {
                    ShowPADetails(_pacompanyid, _painsid);
                }
            }

            cbIsMedicalExpA.Attributes.Add("onClick", "javascript:MedicalExpenseApplicableA(this);");
            cbIsMedicalExpC.Attributes.Add("onClick", "javascript:MedicalExpenseApplicableC(this);");
            cbIsHaspitalCPDA.Attributes.Add("onClick", "javascript:HospitalCPDApplicableA(this);");
            cbIsHaspitalCPDC.Attributes.Add("onClick", "javascript:HospitalCPDApplicableC(this);");
            cbIsRecuperation.Attributes.Add("onClick", "javascript:RecuperationApplicable(this);");
            cbIsBereavement.Attributes.Add("onClick", "javascript:BereavementApplicable(this);");
            cbIsTempTotDisPW.Attributes.Add("onClick", "javascript:TempTotDisPWApplicable(this);");
            cbIsTempPartDisPW.Attributes.Add("onClick", "javascript:TempPartDisPWApplicable(this);");
            cbIsDentalTreatment.Attributes.Add("onClick", "javascript:DentalTreatmentApplicable(this);");
            cbIsChineseMedicalExpenses.Attributes.Add("onClick", "javascript:ChineseMedicalExpensesApplicable(this);");
            cbIsCompassionateCash.Attributes.Add("onClick", "javascript:CompassionateCashApplicable(this);");
            cbIsKidnapBenefit.Attributes.Add("onClick", "javascript:KidnapBenefitApplicable(this);");
        }
    }

    protected void ddlPolicyType_SelectedIndexChanged(object sender, EventArgs e)
    {
        //if (ddlPolicyType.Text == "IND" || ddlPolicyType.Text == "INDSP" || ddlPolicyType.Text == "-1")
        //{
        //    pnlAcciDeathChild.Visible = false;
        //    pnlTotPerDisableChild.Visible = false;
        //    pnlMedicalExpensesChild.Visible = false;
        //    pnlHExpencePerDayChild.Visible = false;

        //    rfvAccidentalDeathChild.Enabled = false;
        //    revAccidentalDeathChild.Enabled = false;
        //    rfvTotPerDisableChild.Enabled = false;
        //    revTotPerDisableChild.Enabled = false;
        //    rfvMedicalExpensesChild.Enabled = false;
        //    revMedicalExpensesChild.Enabled = false;
        //    rfvHCashPerDayChild.Enabled = false;
        //    revHCashPerDayChild.Enabled = false;

        //}
        //else if (ddlPolicyType.Text == "INDCHD" || ddlPolicyType.Text == "INDSPCHD")
        //{
        //    pnlAcciDeathChild.Visible = true;
        //    pnlTotPerDisableChild.Visible = true;
        //    pnlMedicalExpensesChild.Visible = true;
        //    pnlHExpencePerDayChild.Visible = true;

        //    rfvAccidentalDeathChild.Enabled = true;
        //    revAccidentalDeathChild.Enabled = true;
        //    rfvTotPerDisableChild.Enabled = true;
        //    revTotPerDisableChild.Enabled = true;
        //    rfvMedicalExpensesChild.Enabled = true;
        //    revMedicalExpensesChild.Enabled = true;
        //    rfvHCashPerDayChild.Enabled = true;
        //    revHCashPerDayChild.Enabled = true;
        //}
        pnlAcciDeathChild.Visible = false;
        pnlTotPerDisableChild.Visible = false;
        pnlMedicalExpensesChild.Visible = false;
        pnlHExpencePerDayChild.Visible = false;

        rfvAccidentalDeathChild.Enabled = false;
        revAccidentalDeathChild.Enabled = false;
        rfvTotPerDisableChild.Enabled = false;
        revTotPerDisableChild.Enabled = false;
        rfvMedicalExpensesChild.Enabled = false;
        revMedicalExpensesChild.Enabled = false;
        rfvHCashPerDayChild.Enabled = false;
        revHCashPerDayChild.Enabled = false;


        if((ddlPolicyType.Text == "IND")  || (ddlPolicyType.Text == "-1"))
        {
            pnlAPSpouse.Visible = false;
            pnlAPChild.Visible = false;
            revAnnualPremiumSpouse.Enabled = false;
            revAnnualPremiumChild.Enabled = false;
        }
        else if (ddlPolicyType.Text == "INDSP")
        {
            pnlAPSpouse.Visible = true;
            pnlAPChild.Visible = false;
            revAnnualPremiumSpouse.Enabled = true;
            revAnnualPremiumChild.Enabled = false;
        }
        else if (ddlPolicyType.Text == "INDCHD")
        {
            pnlAPSpouse.Visible = false;
            pnlAPChild.Visible = true;
            revAnnualPremiumSpouse.Enabled = false;
            revAnnualPremiumChild.Enabled = true;
        }
        else if (ddlPolicyType.Text == "INDSPCHD")
        {
            pnlAPSpouse.Visible = true;
            pnlAPChild.Visible = true;
            revAnnualPremiumSpouse.Enabled = true;
            revAnnualPremiumChild.Enabled = true;
        }

    }

    protected void ibtSubmit_Click(object sender, ImageClickEventArgs e)
    {
        if (Page.IsValid)
        {
            CompareBenefits _comparebenefits = new CompareBenefits();
            CompareBenefitsDB _comparebenefitsdb = new CompareBenefitsDB();

            _comparebenefits.IsMedicalExpA = true;
            //_comparebenefits.IsMedicalExpC = true;
            _comparebenefits.IsHaspitalCPDA = true;
            //_comparebenefits.IsHaspitalCPDC = true;
            _comparebenefits.IsRecuperation = true;
            _comparebenefits.IsBereavement = true;
            _comparebenefits.IsTempTotDisPW = true;
            _comparebenefits.IsTempPartDisPW = true;

            _comparebenefits.IsDentalTreatment = true;
            _comparebenefits.IsChineseMedicalExpenses = true;
            _comparebenefits.IsCompassionateCash = true;
            _comparebenefits.IsKidnapBenefit = true;

            Int64 _painsid = 0;
            _comparebenefits.PAInsId = Convert.ToInt64(lblPAInsId.Text.Trim());
            _comparebenefits.PACompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _comparebenefits.PlanName = txtPlanName.Text.Trim();
            _comparebenefits.BenefitName = txtBenefitName.Text.Trim();
            _comparebenefits.PolicyType = ddlPolicyType.Text;

            if (ddlPolicyType.Text == "IND")
            {
                _comparebenefits.AnnualPremiumInd = Convert.ToSingle(txtAnnualPremium.Text.ToString());
                _comparebenefits.AnnualPremiumSpouse = 0;
                _comparebenefits.AnnualPremiumChild = 0;
                _comparebenefits.TotalAnnualPremium = Convert.ToSingle(txtAnnualPremium.Text.ToString());
            }
            else if (ddlPolicyType.Text == "INDSP")
            {
                _comparebenefits.AnnualPremiumInd = Convert.ToSingle(txtAnnualPremium.Text.ToString());
                _comparebenefits.AnnualPremiumSpouse = Convert.ToSingle(txtAnnualPremiumSpouse.Text.ToString());
                _comparebenefits.AnnualPremiumChild = 0;
                _comparebenefits.TotalAnnualPremium = Convert.ToSingle(txtAnnualPremium.Text.ToString()) 
                                                    + Convert.ToSingle(txtAnnualPremiumSpouse.Text.ToString());
            }
            else if (ddlPolicyType.Text == "INDCHD")
            {
                _comparebenefits.AnnualPremiumInd = Convert.ToSingle(txtAnnualPremium.Text.ToString());
                _comparebenefits.AnnualPremiumSpouse = 0;
                _comparebenefits.AnnualPremiumChild = Convert.ToSingle(txtAnnualPremiumChild.Text.ToString());
                _comparebenefits.TotalAnnualPremium = Convert.ToSingle(txtAnnualPremium.Text.ToString())
                                                    + Convert.ToSingle(txtAnnualPremiumChild.Text.ToString());
            }
            else if (ddlPolicyType.Text == "INDSPCHD")
            {
                _comparebenefits.AnnualPremiumInd = Convert.ToSingle(txtAnnualPremium.Text.ToString());
                _comparebenefits.AnnualPremiumSpouse = Convert.ToSingle(txtAnnualPremiumSpouse.Text.ToString());
                _comparebenefits.AnnualPremiumChild = Convert.ToSingle(txtAnnualPremiumChild.Text.ToString());
                _comparebenefits.TotalAnnualPremium = Convert.ToSingle(txtAnnualPremium.Text.ToString())
                                                    + Convert.ToSingle(txtAnnualPremiumSpouse.Text.ToString())
                                                    + Convert.ToSingle(txtAnnualPremiumChild.Text.ToString());
            }
            //_comparebenefits.AnnualPremium = Convert.ToSingle(txtAnnualPremium.Text.ToString());
            if(cbIsMedicalExpA.Checked)
            {
                _comparebenefits.IsMedicalExpA = false;
            }
            //if (cbIsMedicalExpC.Checked)
            //{
            //    _comparebenefits.IsMedicalExpC = false;
            //}
            if (cbIsHaspitalCPDA.Checked)
            {
                _comparebenefits.IsHaspitalCPDA = false;
            }
            //if (cbIsHaspitalCPDC.Checked)
            //{
            //    _comparebenefits.IsHaspitalCPDC = false;
            //}

            _comparebenefits.DeathAdult = Convert.ToSingle(txtAccidentalDeathAdult.Text.ToString());
            _comparebenefits.TPDAdult = Convert.ToSingle(txtTotPerDisableAdult.Text.ToString());
            _comparebenefits.MedExpAdult = Convert.ToSingle(txtMedicalExpensesAdult.Text.ToString());
            _comparebenefits.HCPDAdult = Convert.ToSingle(txtHCashPerDayAdult.Text.ToString());

            //Sakthi on 13 Dec 2010 -- Start
            if (cbIsDentalTreatment.Checked)
            {
                _comparebenefits.IsDentalTreatment = false;
            }
            _comparebenefits.DentalTreatment = Convert.ToSingle(txtDentalTreatment.Text.ToString());
            if (cbIsChineseMedicalExpenses.Checked)
            {
                _comparebenefits.IsChineseMedicalExpenses = false;
            }
            _comparebenefits.ChineseMedicalExpenses = Convert.ToSingle(txtChineseMedicalExpenses.Text.ToString());
            //Sakthi on 13 Dec 2010 -- End


            //if (ddlPolicyType.Text == "IND" || ddlPolicyType.Text == "INDSP")
            //{
            //    _comparebenefits.DeathAdult = Convert.ToSingle(txtAccidentalDeathAdult.Text.ToString());
            //    _comparebenefits.TPDAdult = Convert.ToSingle(txtTotPerDisableAdult.Text.ToString());
            //    _comparebenefits.MedExpAdult = Convert.ToSingle(txtMedicalExpensesAdult.Text.ToString());
            //    _comparebenefits.HCPDAdult = Convert.ToSingle(txtHCashPerDayAdult.Text.ToString());
            //}
            //else if (ddlPolicyType.Text == "INDCHD" || ddlPolicyType.Text == "INDSPCHD")
            //{
            //    _comparebenefits.DeathAdult = Convert.ToSingle(txtAccidentalDeathAdult.Text.ToString());
            //    _comparebenefits.DeathChild = Convert.ToSingle(txtAccidentalDeathChild.Text.ToString());

            //    _comparebenefits.TPDAdult = Convert.ToSingle(txtTotPerDisableAdult.Text.ToString());
            //    _comparebenefits.TPDChild = Convert.ToSingle(txtTotPerDisableChild.Text.ToString());

            //    _comparebenefits.MedExpAdult = Convert.ToSingle(txtMedicalExpensesAdult.Text.ToString());
            //    _comparebenefits.MedExpChild = Convert.ToSingle(txtMedicalExpensesChild.Text.ToString());

            //    _comparebenefits.HCPDAdult = Convert.ToSingle(txtHCashPerDayAdult.Text.ToString());
            //    _comparebenefits.HCPDChild = Convert.ToSingle(txtHCashPerDayChild.Text.ToString());
            //}
            if (cbIsRecuperation.Checked)
            {
                _comparebenefits.IsRecuperation = false;
            }
            _comparebenefits.RecupBenefit = Convert.ToSingle(txtRecupBenefit.Text.ToString());
            if (cbIsBereavement.Checked)
            {
                _comparebenefits.IsBereavement = false;
            }
            _comparebenefits.BereaveRelief = Convert.ToSingle(txtBereaveRelief.Text.ToString());
            _comparebenefits.DoubleIndemnity = chkDoubleIndemnity.Checked;
            if (cbIsTempTotDisPW.Checked)
            {
                _comparebenefits.IsTempTotDisPW = false;
            }
            _comparebenefits.TempTDPW = Convert.ToSingle(txtTempTotalDisable.Text.ToString());
            if (cbIsTempPartDisPW.Checked)
            {
                _comparebenefits.IsTempPartDisPW = false;
            }
            _comparebenefits.TempPDPW = Convert.ToSingle(txtTempParialDisable.Text.ToString());


            //Sakthi on 13 Dec 2010 -- Start
            if (cbIsCompassionateCash.Checked)
            {
                _comparebenefits.IsCompassionateCash = false;
            }
            _comparebenefits.CompassionateCash = Convert.ToSingle(txtCompassionateCash.Text.ToString());
            if (cbIsKidnapBenefit.Checked)
            {
                _comparebenefits.IsKidnapBenefit = false;
            }
            _comparebenefits.KidnapBenefit = Convert.ToSingle(txtKidnapBenefit.Text.ToString());
            //Sakthi on 13 Dec 2010 -- End

            _comparebenefits.Terrorism = chkTerrorism.Checked;
            _comparebenefits.Class1 = chkClass1.Checked;
            _comparebenefits.Class2 = chkClass2.Checked;
            _comparebenefits.Class3 = chkClass3.Checked;
            _comparebenefits.Class4 = chkClass4.Checked;
            _comparebenefits.AgeLimitFrom = Convert.ToInt32(txtAgeLimitFrom.Text.ToString());
            _comparebenefits.AgeLimitTo= Convert.ToInt32(txtAgeLimitTo.Text.ToString());
            _comparebenefits.Status = chkStatus.Checked;
            _comparebenefits.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _painsid = _comparebenefitsdb.Insert(_comparebenefits);
            if (_painsid > 0)
            {
                Response.Redirect("~/Provider/PersonalAccident/ViewPAInsurance.aspx");
            }
        }
    }

    protected void btnNew_Click(object sender, ImageClickEventArgs e)
    {
        ClearProcess();
    }

    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/PersonalAccident/PAInsuranceHome.aspx");
    }

    private void ShowPADetails(Int64 PACompanyId, Int64 PAInsId)
    {
        CompareBenefits _comparebenefits = new CompareBenefits();
        CompareBenefitsDB _comparebenefitsdb = new CompareBenefitsDB();
        _comparebenefits = _comparebenefitsdb.GetCompareBenefits(PACompanyId, PAInsId);

        if (_comparebenefits != null)
        {
            lblPAInsId.Text = _comparebenefits.PAInsId.ToString();
            txtPlanName.Text = _comparebenefits.PlanName.ToString();
            txtBenefitName.Text = _comparebenefits.BenefitName.ToString();
            ddlPolicyType.SelectedValue = _comparebenefits.PolicyType.ToString();
            if (ddlPolicyType.Text == "IND")
            {
                pnlAPSpouse.Visible = false;
                pnlAPChild.Visible = false;
                revAnnualPremiumSpouse.Enabled = false;
                revAnnualPremiumChild.Enabled = false;
            }
            else if (ddlPolicyType.Text == "INDSP")
            {
                pnlAPSpouse.Visible = true;
                pnlAPChild.Visible = false;
                revAnnualPremiumSpouse.Enabled = true;
                revAnnualPremiumChild.Enabled = false;
            }
            else if (ddlPolicyType.Text == "INDCHD")
            {
                pnlAPSpouse.Visible = false;
                pnlAPChild.Visible = true;
                revAnnualPremiumSpouse.Enabled = false;
                revAnnualPremiumChild.Enabled = true;
            }
            else if (ddlPolicyType.Text == "INDSPCHD")
            {
                pnlAPSpouse.Visible = true;
                pnlAPChild.Visible = true;
                revAnnualPremiumSpouse.Enabled = true;
                revAnnualPremiumChild.Enabled = true;
            }
            chkClass1.Checked = Convert.ToBoolean(_comparebenefits.Class1.ToString());
            chkClass2.Checked = Convert.ToBoolean(_comparebenefits.Class2.ToString());
            chkClass3.Checked = Convert.ToBoolean(_comparebenefits.Class3.ToString());
            chkClass4.Checked = Convert.ToBoolean(_comparebenefits.Class4.ToString());
            txtAnnualPremium.Text = _comparebenefits.AnnualPremiumInd.ToString();
            txtAnnualPremiumSpouse.Text = _comparebenefits.AnnualPremiumSpouse.ToString();
            txtAnnualPremiumChild.Text = _comparebenefits.AnnualPremiumChild.ToString();
            txtAccidentalDeathAdult.Text = _comparebenefits.DeathAdult.ToString();
            txtAccidentalDeathChild.Text = _comparebenefits.DeathChild.ToString();
            txtTotPerDisableAdult.Text = _comparebenefits.TPDAdult.ToString();
            txtTotPerDisableChild.Text = _comparebenefits.TPDChild.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsMedicalExpA.ToString()) == false)
            {
                cbIsMedicalExpA.Checked = true;
            }
            txtMedicalExpensesAdult.Text = _comparebenefits.MedExpAdult.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsMedicalExpC.ToString()) == false)
            {
                cbIsMedicalExpC.Checked = true;
            }
            txtMedicalExpensesChild.Text = _comparebenefits.MedExpChild.ToString();

            //Sakthi on 13 Dec 2010 -- Start
            if (Convert.ToBoolean(_comparebenefits.IsDentalTreatment.ToString()) == false)
            {
                cbIsDentalTreatment.Checked = true;
            }
            txtDentalTreatment.Text = _comparebenefits.DentalTreatment.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsChineseMedicalExpenses.ToString()) == false)
            {
                cbIsChineseMedicalExpenses.Checked = true;
            }
            txtChineseMedicalExpenses.Text = _comparebenefits.ChineseMedicalExpenses.ToString();
            //Sakthi on 13 Dec 2010 -- End

            if (Convert.ToBoolean(_comparebenefits.IsHaspitalCPDA.ToString()) == false)
            {
                cbIsHaspitalCPDA.Checked = true;
            }
            txtHCashPerDayAdult.Text = _comparebenefits.HCPDAdult.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsHaspitalCPDC.ToString()) == false)
            {
                cbIsHaspitalCPDC.Checked = true;
            }
            txtHCashPerDayChild.Text = _comparebenefits.HCPDChild.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsRecuperation.ToString()) == false)
            {
                cbIsRecuperation.Checked = true;
            }
            txtRecupBenefit.Text = _comparebenefits.RecupBenefit.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsBereavement.ToString()) == false)
            {
                cbIsBereavement.Checked = true;
            }
            txtBereaveRelief.Text = _comparebenefits.BereaveRelief.ToString();
            chkDoubleIndemnity.Checked = Convert.ToBoolean(_comparebenefits.DoubleIndemnity.ToString());
            if (Convert.ToBoolean(_comparebenefits.IsTempTotDisPW.ToString()) == false)
            {
                cbIsTempTotDisPW.Checked = true;
            }
            txtTempTotalDisable.Text = _comparebenefits.TempTDPW.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsTempPartDisPW.ToString()) == false)
            {
                cbIsTempPartDisPW.Checked = true;
            }
            txtTempParialDisable.Text = _comparebenefits.TempPDPW.ToString();

            //Sakthi on 13 Dec 2010 -- Start
            if (Convert.ToBoolean(_comparebenefits.IsCompassionateCash.ToString()) == false)
            {
                cbIsCompassionateCash.Checked = true;
            }
            txtCompassionateCash.Text = _comparebenefits.CompassionateCash.ToString();
            if (Convert.ToBoolean(_comparebenefits.IsKidnapBenefit.ToString()) == false)
            {
                cbIsKidnapBenefit.Checked = true;
            }
            txtKidnapBenefit.Text = _comparebenefits.KidnapBenefit.ToString();
            //Sakthi on 13 Dec 2010 -- End

            chkTerrorism.Checked = Convert.ToBoolean(_comparebenefits.Terrorism.ToString());
            txtAgeLimitFrom.Text = _comparebenefits.AgeLimitFrom.ToString();
            txtAgeLimitTo.Text = _comparebenefits.AgeLimitTo.ToString();
            chkStatus.Checked = Convert.ToBoolean(_comparebenefits.Status.ToString());
        }
        IsEnabled();
    }

    private void ClearProcess()
    {
        lblPAInsId.Text = "0";
        txtPlanName.Text = "";
        txtBenefitName.Text = "";
        ddlPolicyType.SelectedValue = "-1";
        chkClass1.Checked = false;
        chkClass2.Checked = false;
        chkClass3.Checked = false;
        chkClass4.Checked = false;
        txtAnnualPremium.Text = "";
        txtAnnualPremiumSpouse.Text = "";
        txtAnnualPremiumChild.Text = "";
        pnlAPSpouse.Visible = false;
        pnlAPChild.Visible = false;
        txtAccidentalDeathAdult.Text = "";
        txtAccidentalDeathChild.Text = "";
        txtTotPerDisableAdult.Text = "";
        txtTotPerDisableChild.Text = "";
        txtMedicalExpensesAdult.Text = "";
        txtMedicalExpensesChild.Text = "";
        txtHCashPerDayAdult.Text = "";
        txtHCashPerDayChild.Text = "";
        txtRecupBenefit.Text = "";
        txtBereaveRelief.Text = "";
        chkDoubleIndemnity.Checked = false;
        txtTempTotalDisable.Text = "";
        txtTempParialDisable.Text = "";
        chkTerrorism.Checked = false;
        txtAgeLimitFrom.Text = "";
        txtAgeLimitTo.Text = "";
        chkStatus.Checked = true;

        cbIsMedicalExpA.Checked = false;
        cbIsMedicalExpC.Checked = false;
        cbIsHaspitalCPDA.Checked = false;
        cbIsHaspitalCPDC.Checked = false;
        cbIsRecuperation.Checked = false;
        cbIsBereavement.Checked = false;
        cbIsTempTotDisPW.Checked = false;
        cbIsTempPartDisPW.Checked = false;

        txtMedicalExpensesAdult.Enabled = true;
        txtMedicalExpensesChild.Enabled = true;
        txtHCashPerDayAdult.Enabled = true;
        txtHCashPerDayChild.Enabled = true;
        txtRecupBenefit.Enabled = true;
        txtBereaveRelief.Enabled = true;
        txtTempTotalDisable.Enabled = true;
        txtTempParialDisable.Enabled = true;

        cbIsDentalTreatment.Checked = false;
        cbIsChineseMedicalExpenses.Checked = false;
        cbIsCompassionateCash.Checked = false;
        cbIsKidnapBenefit.Checked = false;

        txtDentalTreatment.Enabled = true;
        txtChineseMedicalExpenses.Enabled = true;
        txtCompassionateCash.Enabled = true;
        txtKidnapBenefit.Enabled = true;

        txtDentalTreatment.Text = "";
        txtChineseMedicalExpenses.Text = "";
        txtCompassionateCash.Text = "";
        txtKidnapBenefit.Text = "";
    }

    public void IsEnabled()
    {
        if (cbIsMedicalExpA.Checked)
        {
            txtMedicalExpensesAdult.Enabled = false;
        }
        else
        {
            txtMedicalExpensesAdult.Enabled = true;
        }
        if (cbIsMedicalExpC.Checked)
        {
            txtMedicalExpensesChild.Enabled = false;
        }
        else
        {
            txtMedicalExpensesChild.Enabled = true;
        }
        if (cbIsHaspitalCPDA.Checked)
        {
            txtHCashPerDayAdult.Enabled = false;
        }
        else
        {
            txtHCashPerDayAdult.Enabled = true;
        }
        if (cbIsHaspitalCPDC.Checked)
        {
            txtHCashPerDayChild.Enabled = false;
        }
        else
        {
            txtHCashPerDayChild.Enabled = true;
        }
        if (cbIsRecuperation.Checked)
        {
            txtRecupBenefit.Enabled = false;
        }
        else
        {
            txtRecupBenefit.Enabled = true;
        }
        if (cbIsBereavement.Checked)
        {
            txtBereaveRelief.Enabled = false;
        }
        else
        {
            txtBereaveRelief.Enabled = true;
        }
        if (cbIsTempTotDisPW.Checked)
        {
            txtTempTotalDisable.Enabled = false;
        }
        else
        {
            txtTempTotalDisable.Enabled = true;
        }
        if (cbIsTempPartDisPW.Checked)
        {
            txtTempParialDisable.Enabled = false;
        }
        else
        {
            txtTempParialDisable.Enabled = true;
        }
        //New 13 Dec 2010 by Sakthi
        if (cbIsDentalTreatment.Checked)
        {
            txtDentalTreatment.Enabled = false;
        }
        else
        {
            txtDentalTreatment.Enabled = true;
        }
        if (cbIsChineseMedicalExpenses.Checked)
        {
            txtChineseMedicalExpenses.Enabled = false;
        }
        else
        {
            txtChineseMedicalExpenses.Enabled = true;
        }
        if (cbIsCompassionateCash.Checked)
        {
            txtCompassionateCash.Enabled = false;
        }
        else
        {
            txtCompassionateCash.Enabled = true;
        }
        if (cbIsKidnapBenefit.Checked)
        {
            txtKidnapBenefit.Enabled = false;
        }
        else
        {
            txtKidnapBenefit.Enabled = true;
        }
    }

    private void CheckMainPageAccess()
    {
        Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), PageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
    }

    private void CheckSubPageAccess()
    {
        Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), SubPageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
        else if (PageAccess == 100)
        {
            ibtSubmit.Enabled = false;
            btnNew.Enabled = false;
            //btnDelete.Enabled = false;
        }
        else if (PageAccess == 200)
        {
            ibtSubmit.Enabled = true;
            btnNew.Enabled = true;
            //btnDelete.Enabled = false;
        }
        else if (PageAccess == 300)
        {
            ibtSubmit.Enabled = true;
            btnNew.Enabled = true;
            //btnDelete.Enabled = true;
        }
    }

}
